import java.util.*;

public class Solution699 {

    static class SegmentTree{
        int left;
        int right;
        int val;
        int lazy;
        SegmentTree leftTree;
        SegmentTree rightTree;

        SegmentTree build(int l,int r){
            left=l;
            right=r;
            if (l!=r) {
                int mid=(l+r)/2;
                leftTree=new SegmentTree();
                leftTree.build(l,mid);
                rightTree=new SegmentTree();
                rightTree.build(mid+1,r);
            }
            return this;
        }

        void update(int l,int r,int val){
            push();
            if (right<l || left>r){
                return;
            }
            if (left>=l && right<=r){
                this.val=Math.max(this.val,val);
                this.lazy=Math.max(this.lazy,val);
                return;
            }
            leftTree.update(l,r,val);
            rightTree.update(l,r,val);
            this.val=Math.max(leftTree.val,rightTree.val);
        }

        private void push() {
            if (lazy!=0){
                if (leftTree!=null){
                    leftTree.val=Math.max(leftTree.val,lazy);
                    leftTree.lazy=Math.max(leftTree.lazy,lazy);
                }
                if (rightTree!=null){
                    rightTree.val=Math.max(rightTree.val,lazy);
                    rightTree.lazy=Math.max(rightTree.lazy,lazy);
                }
            }
        }

        int query(int l,int r){
            push();
            if (right<l || left>r){
                return 0;
            }
            if (left>=l && right<=r){
                return val;
            }
            return Math.max(leftTree.query(l,r),rightTree.query(l,r));
        }
    }

    public List<Integer> fallingSquares(int[][] positions) {
        TreeSet<Integer> set=new TreeSet<>();
        for (int[] position : positions) {
            set.add(position[0]);
            set.add(position[0]+position[1]-1);
        }
        Map<Integer,Integer> map=new HashMap<>();
        int index=0;
        for (Integer integer : set) {
            index++;
            map.put(integer,index);
        }
        List<Integer> list=new ArrayList<>();
        SegmentTree segmentTree=new SegmentTree();
        segmentTree.build(1,index);
        for (int[] position : positions) {
            int high=segmentTree.query(map.get(position[0]),map.get(position[0]+position[1]-1));
            segmentTree.update(map.get(position[0]),map.get(position[0]+position[1]-1),high+position[1]);
            list.add(segmentTree.query(1,index));
        }
        return list;
    }

    public static void main(String[] args) {
        System.out.println(new Solution699().fallingSquares(new int[][]{{1,2},{2,3},{6,1}}));
    }
}
